<template>
	<view style="background-color: #f3f4f5;">
		<u-navbar :is-back="true" title="工作安排修改" :border-bottom="false" :background="background">
			<view class="navbar-right" slot="right" style="color: #FFFFFF;margin-right: 20rpx;" @click="deleteClick()">
				删除
			</view>
		</u-navbar>
		<view class="u-p-15 u-font-12" style="background-color: #f3f4f5;color: #b2b2b2;">
			添加工作安排后，该周期内无法接受患者预约/咨询。
		</view>
		<view class="" style="padding: 0rpx 26rpx;background-color: #FFFFFF;">
			<u-cell-group class="u-m-b-26" style="margin-bottom: 20rpx;">
				<u-cell-item title="开始时间" @click="pickerShowTimebegin()" :value="startTime"></u-cell-item>
				<!-- 弹出picker时间 -->
				<u-picker v-model="showTimebegin" title="选择日期" mode="time" @confirm="timeBeginChange" :params="params">
				</u-picker>
				<u-cell-item title="结束时间" @click="pickerShowTimeend()" :value="endTime"></u-cell-item>
				<!-- 弹出picker时间 -->
				<u-picker v-model="showTimeend" title="选择日期" mode="time" @confirm="timeEndChange" :params="params">
				</u-picker>
			</u-cell-group>
			<u-cell-group class="u-m-b-26" style="margin-bottom: 20rpx;">
				<u-cell-item title="已有其他工作安排" :arrow="false">
					<u-checkbox-group @change="checkboxGroupChange">
						<u-checkbox shape="circle" @change="checkboxChange" v-model="item.checked"
							v-for="(item, index) in list1" :key="index" :name="item.name"></u-checkbox>
					</u-checkbox-group>
				</u-cell-item>

				<u-cell-item title="个人调休" :arrow="false">
					<u-checkbox-group @change="checkboxGroupChange">
						<u-checkbox shape="circle" @change="checkboxChange" v-model="item.checked"
							v-for="(item, index) in list2" :key="index" :name="item.name"></u-checkbox>
					</u-checkbox-group>
				</u-cell-item>

				<u-cell-item title="其他原因" :arrow="false">
					<u-checkbox-group @change="checkboxGroupChange">
						<u-checkbox shape="circle" @change="checkboxChange" v-model="item.checked"
							v-for="(item, index) in list3" :key="index" :name="item.name"></u-checkbox>
					</u-checkbox-group>
				</u-cell-item>
			</u-cell-group>
		</view>
		<u-button type="primary" style="width: 90%;position: fixed;bottom: 60rpx;left: 5%;" @click="updateClick()">确认修改
		</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#00a8ff'
				},
				showTimebegin: false,
				showTimeend: false,
				params: {
					year: false,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: false
				},
				list1: [{
					checked: false,
					disabled: false
				}],
				list2: [{
					checked: false,
					disabled: false
				}],
				list3: [{
					checked: false,
					disabled: false
				}],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				value: 'orange',
				startTime: '',
				endTime: '',
				startTimestamp: '',
				endTimestamp: '',
				msg:''
			}
		},
		onLoad(e) {
			// console.log(e.startTime+e.endTime)
			this.startTime = e.startTime;
			this.endTime = e.endTime;
		},
		methods: {
			pickerShowTimebegin() {
				this.showTimebegin = true;
			},
			pickerShowTimeend() {
				this.showTimeend = true;
			},
			// 选中某个复选框时，由checkbox时触发
			checkboxChange(e) {
				console.log(e);
				
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				console.log(e);
				console
			},

			// 开始时间 结束时间pick回调函数

			timeBeginChange(e) {
				this.startTime = e.month + "月" + e.day + "日 " + e.hour + ":" + e.minute;
				let dt = "";
				let year = new Date().getFullYear();
				dt = year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute;
				var timestamp1 = (new Date(dt)).getTime() / 1000
				console.log("时间戳:", timestamp1);
				console.log("日期:", dt);
				this.startTimestamp=timestamp1;// 开始时间戳
			},
			timeEndChange(e) {
				this.endTime = e.month + "月" + e.day + "日 " + e.hour + ":" + e.minute;
				let dt = "";
				let year = new Date().getFullYear();
				dt = year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute;
				var timestamp1 = (new Date(dt)).getTime() / 1000
				console.log("时间戳:", timestamp1);
				console.log("日期:", dt);
				this.endTimestamp=timestamp1;// 结束时间戳
			},
			updateClick() {
				console.log("执行确认修改");
				this.$apiVipCentre.setroster({
					starttime:this.startTimestamp,
					endtime:this.endTimestamp,
					msg:"ss",
					type:"a"
				}).then((res) => {
					console.log("res.data.data: ", res.data.data);
					// this.rosterlist = res.data.data.items;

				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			deleteClick() {
				console.log("删除,发送请求删除，然后跳转我的，逻辑跳转有问题");

				uni.navigateTo({
					url: "/pages/order/makeTable/addArrange/myArrange/myArrange",
				});
			},
			openinfo(url) {
				uni.navigateTo({
					url: url,
				});
			}
		}
	}
</script>

<style>

</style>
